import { createSelector, createFeatureSelector } from '@ngrx/store';
import { PlayState } from '../entity';

export const selectPlayState = (state: PlayState) => state;

export const getPlayer = createFeatureSelector<PlayState>('player');
export const getPlaying = createSelector(selectPlayState, (state: PlayState) => state.playing);
export const getPlayList = createSelector(selectPlayState, (state: PlayState) => state.playList);
export const getPlayMode = createSelector(selectPlayState, (state: PlayState) => state.playMode);
export const getSongList = createSelector(selectPlayState, (state: PlayState) => state.songList);
export const getCurrentIndex = createSelector(selectPlayState, (state: PlayState) => state.currentIndex);
export const getCurrentSong = createSelector(selectPlayState, ({playList, currentIndex}: PlayState) => playList[currentIndex]);
